<template>
    <div v-loading="loading" element-loading-text="拼命加载中">
        <el-row>
            <!--<div class="search-wrapper">
                <ul class="search-box">
                    <li><span class="filter-name">部件类型：</span>
                        <el-select v-model="listQuery.partType" placeholder="请选择" clearable style="width:130px"
                                   class="filter-item">
                            <el-option v-for="item in partType" :key="item.dictId" :label="item.dictName" :value="item.dictValue"/>
                        </el-select>
                    </li>
                    <li><span class="filter-name">所属街道：</span>
                        <el-input v-model="listQuery.belongStreet" placeholder="请输入内容"></el-input>
                    </li>
                    <li style="padding-left:10px;">
                        <el-button style="vertical-align:middle;margin-top:-2px;" round size="mini" type="primary"
                                   @click="getList()">查询
                        </el-button>
                    </li>
                </ul>

            </div>-->
            <div class="search-box">
                <el-form :inline="true" :model="listQuery"  class="demo-form-inline">
                <el-form-item label="部件类型：">
                    <el-select v-model="listQuery.partType" placeholder="请选择" clearable style="width:130px"
                               class="filter-item">
                        <el-option v-for="item in partType" :key="item.dictId" :label="item.dictName" :value="item.dictValue"/>
                    </el-select>
                </el-form-item>

                    <el-form-item label="所属街道：">
                        <el-input v-model="listQuery.belongStreet" placeholder="所属街道"></el-input>
                    </el-form-item>

                    <el-form-item>
                        <el-button round size="mini" type="primary" @click="getList()">查询</el-button>
                    </el-form-item>
                </el-form>
            </div>

        </el-row>
        <!-- 表格 -->
        <el-row>
            <el-col :span="24">
                <div class="data-wrapper">
                    <template v-if="tableData!=null">
                        <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%">
                            <el-table-column type="index" label="序号" width="100" :index="indexMethod">
                            </el-table-column>
                            <el-table-column prop="partsCode" label="部件编码" width="140">
                            </el-table-column>
                            <el-table-column prop="partsName" label="部件名称" width="150">
                            </el-table-column>
                            <el-table-column prop="partsType.name" label="部件类型" width="150">
                            </el-table-column>
                            <el-table-column prop="partsFlow" label="所属街道" width="150">
                            </el-table-column>
                            </el-table-column>
                            <el-table-column prop="regId.name" label="所属区域" width="110">
                            </el-table-column>
                            <el-table-column prop="riverId.name" label="处于河流段" width="140">
                            </el-table-column>
                            <el-table-column label="经纬度" width="90">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.longitude}}/{{ scope.row.latitude}}</span>
                                </template>
                            </el-table-column>
                            <el-table-column prop="" label="GIS地图" >
                            </el-table-column>

                        </el-table>
                    </template>
                </div>
            </el-col>
        </el-row>
        <!-- 底部按钮和分页 -->
        <el-row :gutter="20" v-if="dataCount" type="flex" justify="space-between" align="center" class="page-wrapper">
            <el-col :span="20">
                <div class="page-item">
                    <el-pagination background
                                   @size-change="handleSizeChange"
                                   @current-change="handleCurrentChange"
                                   :current-page.sync="listQuery.page"
                                   :page-sizes="pageSizes"
                                   :page-size="listQuery.limit"
                                   layout="total, sizes, prev, pager, next, jumper"
                                   :total="dataCount"/>
                </div>
            </el-col>
        </el-row>
        <!-- 弹出窗口区域 -->
    </div>
</template>
<script>
    export default {
        data() {
            return {
                partType: [],
                partStreet: [],
                partRiver: [],
                tableData: [],
                tableDataAll: [],
                //默认数据总数
                dataCount: 100,
                pageSizes: [5, 10, 20, 30, 40],
                //查询条件
                listQuery: {
                    partType: '', //查询条件存放1
                    belongStreet: '', //查询条件存放2
                    belongRiver: '',//查询条件存放3
                    page: 1,
                    limit: 5
                },
                chcek: false,//查看时显示,默认隐藏选项
                isView: true,//保存按钮是否显示，默认显示
                listSelect: [],
                dialogFormVisible: false,
                showDialog: false,
                editdialogForm: false,
                loading: false,
                dis:true,
                form: {},
                oneCol: {},
                formLabelWidth: '100px',
            }
        },
        mounted() {
            this.getList(); //初始化页面是数据
            this.getTypeOption();//对河道类型下拉框取值
            this.getStreetOption()//对所属街道和所属河段下拉框查询
        },
        methods: {
            // 状态翻译
            formatState: function (row, column) {
                return row.parts_state == 0 ? "启用" : "停用";
            },
            // 页面刷新
            getList() {
                this.loading = true;
                this.postRequest('/api/rcs/getPartsList', this.listQuery).then((res) => {
                    var data = res.data;
                    console.log('表格数据：',res.data);
                    if (data.status == 200) {
                        this.tableData = data.data;
                        this.dataCount = data.count;
                    } else {
                        this.$message.error(data.msg);
                    }
                    this.loading = false
                }).catch(error => { //错误信息
                    this.$message.error(error);
                })
            },
            getTypeOption() {
                this.getDictionary({types:["PARTIS_TYPE"]}).then(res => {
                    var data = res.data;
                    if (data.status == 200) {
                        this.partType = data.data["PARTIS_TYPE"];
                    } else {
                        this.$message.error(data.msg);
                    }
                }) .catch(error => {
                    //错误信息
                    this.$message.error(error);
                });
            },
            getStreetOption() {
                this.postRequest('/api/rcs/getStreetList').then((res) => {
                    var data = res.data;
                    console.log(data.status == 200);
                    if (data.status == 200) {
                        this.partStreet = data.data[0]; //街道选项
                        this.partRiver = data.data[1]; //所属河段选项
                        console.log('this.partStreet',this.partStreet);
                    } else {
                        this.$message.error(data.msg);
                    }

                }).catch((error) => {//错误信息
                    console.log(error)
                })
            },
            indexMethod(index) {
                return index + 1;
            },
            //每页个数改变
            handleSizeChange(size) {
                this.listQuery.limit = size;
                this.listQuery.page = 1;
                this.getList()
            },
            //当前页改变
            handleCurrentChange(currentPage) {
                this.listQuery.page = currentPage;
                this.getList()
            },
        }
    }
</script>
<style scoped>

</style>
